package com.lpf;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;

public class Demo {

    public static void main(String[] args) throws IOException {

        ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
        serverSocketChannel.socket().bind(new InetSocketAddress("127.0.0.1", 9999));
        serverSocketChannel.configureBlocking(false);

        Selector selector01 = Selector.open();
        Selector selector02 = Selector.open();

        serverSocketChannel.register(selector01, SelectionKey.OP_ACCEPT);
        serverSocketChannel.register(selector02, SelectionKey.OP_ACCEPT);

        System.out.println(selector01);
        System.out.println(selector02);

        selector01.select();
        selector02.select();

        selector01.selectedKeys();

    }
}
